import javax.bluetooth.*;

public class LocalBluetoothInfo {

	public static void main(String args[]) {
		LocalDevice btDevice = null;
		long tnano_start;
		long tms_start;
		try {
			tms_start = System.currentTimeMillis();
			tnano_start = System.nanoTime();
			btDevice = LocalDevice.getLocalDevice();
			System.out.println("[Time used]" + (System.nanoTime() - tnano_start) + "ns");
			System.out.println("[Time used]" + (System.currentTimeMillis() - tms_start) + "ms");
		} catch (BluetoothStateException e) {
			// TODO: handle exception
			e.printStackTrace();
			System.exit(1);
		}

		// get local bluetooth device
		/* print local bluetooth info. */
		System.out.println("A local Bluetooth device is found");
		System.out.println("isDiscoverable: " + (btDevice.getDiscoverable() == 0 ? false : true));
		System.out.println("Name:" + btDevice.getFriendlyName());
		System.out.println("Address: " + btDevice.getBluetoothAddress());
		System.out.println("\nIts device classes are:");
		DeviceClass devcla = btDevice.getDeviceClass();
		System.out.println(devcla.toString());
		System.out.println("Service Class: " + devcla.getServiceClasses());
		System.out.println("Major Device Class: "
				+ devcla.getMajorDeviceClass());
		System.out.println("Minor Device Class: "
				+ devcla.getMinorDeviceClass());	
		
		/* print other info. about local bluetooth stack */
		System.out.println("Bluetooth Version:" + btDevice.getProperty("bluetooth.api.version"));
		System.out.println("Bluetooth Max num. of records once retrievable: "
				+ btDevice.getProperty("bluetooth.sd.attr.retrievable.max"));
		System.out.println("Bluetooth Max num. of connected devices: "
				+ btDevice.getProperty("bluetooth.connected.devices.max"));
		System.out.println("Bluetooth max transactions of service discovery: "
				+ btDevice.getProperty("bluetooth.sd.trans.max"));
		System.out.println("Bluetooth MTU size: "
				+ btDevice.getProperty("bluetooth.l2cap.receiveMTU.max"));
	}
}
